package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.CustomFormElement;
import org.deadline.repository.config.CustomFormElementRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class CustomFormElementServiceImpl implements CustomFormElementService {

	@Autowired
    CustomFormElementRepository customFormElementRepository;

	public long countAllCustomFormElements() {
        return customFormElementRepository.count();
    }

	public void deleteCustomFormElement(CustomFormElement customFormElement) {
        customFormElementRepository.delete(customFormElement);
    }

	public CustomFormElement findCustomFormElement(Long id) {
        return customFormElementRepository.findOne(id);
    }

	public List<CustomFormElement> findAllCustomFormElements() {
        return customFormElementRepository.findAll();
    }

	public List<CustomFormElement> findCustomFormElementEntries(int firstResult, int maxResults) {
        return customFormElementRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveCustomFormElement(CustomFormElement customFormElement) {
        customFormElementRepository.save(customFormElement);
    }

	public CustomFormElement updateCustomFormElement(CustomFormElement customFormElement) {
        return customFormElementRepository.save(customFormElement);
    }
}
